<?php

namespace App\Http\Requests\Api;

use Dingo\Api\Http\FormRequest;

class SocialAuthorizationRequest extends FormRequest
{
    public function authorize()
    {
        return true;
    }

    public function rules()
    {
        $rules = [
            'code' => 'required_without:access_token|string',
            'access_token' => 'required_without:code|string',
            'state' => 'nullable|string',
        ];

        if ($this->social_type == 'weibo' && !$this->code) {
            $rules['uid']  = 'required|string';
        }
        if ($this->social_type == 'qq') {
            $rules['state']  = 'required|string';
        }
        return $rules;
    }
}
